<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport"
          content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>完成服务</title>
    <%- include('./_global/baseLibsYs') %>
    <link rel="stylesheet" src="/static/css/reset.css"/>
    <link rel="stylesheet" src="/static/css/mycontract.css"/>

    <style>
        .message-first-box ul{
            height: 3.33rem;
            background: white;
            margin-top: 5px;
        }
        .right-li{
            float: left;
            height:100%;
            line-height: 3.33rem;
            width:50%;
            padding-left: 1.9rem;
            color: #9d9d9d;
        }
        #text{
            margin-top: 10px;
            width: 100%;
            min-height: 60px;
        }
        .qd-btn{
            width: 90%;
            height: 3.04762rem;
            line-height: 3.04762rem;
            display: block;
            border: 1px solid #087cff;
            color: #087cff;
            border-radius: 4px;
            font-size: 1.33333rem;
            text-align: center;
            text-decoration: none;
            cursor: pointer;
            margin: 3rem auto;
        }
    </style>

</head>
<body>

<div class="message-box message-box2">
    <header class="header-box grey fixed">
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">完成服务</div>
        </div>
    </header>
    <div class="message-first-box">
        <ul>
            <li class="right-li">
                <span class="black-text">
                	<span>服务时间：</span>
                	<span name="WCFWSJ" id="WCFWSJ"></span>
                </span>
            </li>
            <li class="right-li">
                <span class="black-text"><span>服务医生：</span><span name="DQYSXM"></span></span>
            </li>
        </ul>
    </div>
</div>

<div class="pj-text-box">
    <textarea id="text" onfocus="clearText(this)" onblur="text(this);">

    </textarea>
    <div id="tip">请输入服务内容的描述</div>
</div>

<div class="tj-btn-box">
    <a href="javascript:void(0)" class="qd-btn" id="submit">提交</a>
</div>

<script>
    var userYsInfo = StoreCache.getCache("jkcsUserInfo-ys");
    var ysdHzInfo = StoreCache.getCache("ysdHzInfo");
    var qyfwUserId = StoreCache.getCache("qyfwUserId");


    var page_wcfw = (function($, page_wcfw) {

        function inintView() {
            $("[name=DQYSXM]").html(userYsInfo.xm);
            var nowDate = new Date().Format("yyyy-MM-dd");
            $("[name=WCFWSJ]").html(nowDate);
        }


        /** 完成服务  */
        function qyjmWcfw() {

            var textval=$("#text").val();
            var QYFW_FWXX =  StoreCache.getCache("QYFW_FWXX");
            console.log(QYFW_FWXX);
            var prame = {};
            var fpfwArr = [{
                SJFWSJ:$("[name=WCFWSJ]").html(),
                FPFWID :QYFW_FWXX.FPFWIDYS,
//                FPFWID:"13540cbc-f3f2-41c7-9228-54e76166d877",
                BZ:$("#text").val(),
                USERID:qyfwUserId,
                FWZT:"1"
            }];
            prame.fpfwArr=JSON.stringify(fpfwArr);
//            prame2={fpfwid:"13540cbc-f3f2-41c7-9228-54e76166d877",sjfwsj:$("[name=WCFWSJ]").html(),bz:"6666"}
            prame = $.extend(prame,QYFW_FWXX,ysdHzInfo,userYsInfo,{FPFWID :QYFW_FWXX.FPFWIDYS});
//            prame = $.extend(prame,QYFW_FWXX,ysdHzInfo,userYsInfo,{FPFWID :"13540cbc-f3f2-41c7-9228-54e76166d877"});
            prame=page_wcfw.LowerJSONKey(prame);
            var parme1={
                SJFWSJ:$("[name=WCFWSJ]").html(),
                FPFWID :QYFW_FWXX.FPFWIDYS,
                BZ:textval,
            }
            console.log(parme1);
            $.QuickRemote.AjaxJson("/api/doctor/qyfw/finishTask", page_wcfw.qyjmWcfwBack,parme1);

        }

        function LowerJSONKey(jsonObj){
            for (var key in jsonObj){
                jsonObj[key.toLowerCase()] = jsonObj[key];
                delete(jsonObj[key]);
            }
            return jsonObj;
        }

        /** 完成服务回调  */
        function qyjmWcfwBack(result) {
//            if (result.state == "true" || result.state == true) {
            $.QuickAlert.alertNormal("完成服务成功！", {
                callback: function () {
                    StoreCache.setCache("clickBtnIndex", 1);
                    $.QuickUrlUtils.redirectJSBridge({
                        url: "/html/ysd/qyjm/qyjm_index.html",
                        title: "签约居民",
                        "app_user_agent": "qyfw"
                    });
                }
            });
//            } else {
//                $.QuickAlert.alertFail({content: "，请稍候再试.."});
//            }
        }

        function curPoint($li, pNum) {
            if (pNum) {
                iScore = pNum;
            } else {
                iScore = iStar;
            }
            for (i = 0; i < $li.length; i++) {
                if (i < iScore) {
                    $li.eq(i).addClass("active");
                } else {
                    $li.eq(i).removeClass("active");
                }
            }
        }
        function clearText(obj) {
            $('#tip').hide();
        }

        function text(obj) {
            if (obj.value == "") {
                $('#tip').show();
            }
        }

        var cfg_def = {
            inintView: inintView,
            qyjmWcfw: qyjmWcfw,
            LowerJSONKey: LowerJSONKey,
            qyjmWcfwBack: qyjmWcfwBack,
            curPoint: curPoint,
            clearText: clearText,
            text: text,
        }

        page_wcfw.init = function(cfg){
            $.extend(page_wcfw, cfg_def, cfg);
            page_wcfw.inintView();

            $('#submit').click(page_wcfw.qyjmWcfw);
            var $star = $(".star-box");

            $star.each(function (index) {
                //console.log(index);
                var $li = $(this).find("li");
                var $active = $(this).find("active");
                var i = iScore = iStar = 0;
                $li.click(function () {
                    var index = $(this).index() + 1;
                    iStar = $(this).index() + 1;
                    page_wcfw.curPoint($li, index);
                    //$active.text(sText);
                })
            });
            $('#tip').click(function () {
                $('#text').focus()
            });
            $('#text').focus(page_wcfw.clearText)
            $('#text').blur(page_wcfw.text)

        }

        return page_wcfw;
    })(jQuery, {});






</script>

<script>


</script>
</body>
</html>